﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;

namespace Ataric.Themester
{
    /// <summary>
    /// Summary description for PreviewImage
    /// </summary>
    public class PreviewImage : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "image/jpeg";
            string file = context.Request["f"] as string;
            if (string.IsNullOrEmpty(file)) file = "nopreview.jpg";
            string path = context.Server.MapPath("~/App_data/previews/" + file);

            if (!File.Exists(path)) path = context.Server.MapPath("~/App_data/previews/nopreview.jpg");
            context.Response.TransmitFile(path);
            context.Response.End();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}